package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DUserBcd;
import com.ruoyi.system.service.IDUserBcdService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户与他人电子名片绑定记录Controller
 * 
 * @author ruoyi
 * @date 2024-06-21
 */
@Controller
@RequestMapping("/system/bcd")
public class DUserBcdController extends BaseController
{
    private String prefix = "system/bcd";

    @Autowired
    private IDUserBcdService dUserBcdService;

    @RequiresPermissions("system:bcd:view")
    @GetMapping()
    public String bcd()
    {
        return prefix + "/bcd";
    }

    /**
     * 查询用户与他人电子名片绑定记录列表
     */
    @RequiresPermissions("system:bcd:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DUserBcd dUserBcd)
    {
        startPage();
        List<DUserBcd> list = dUserBcdService.selectDUserBcdList(dUserBcd);
        return getDataTable(list);
    }

    /**
     * 导出用户与他人电子名片绑定记录列表
     */
    @RequiresPermissions("system:bcd:export")
    @Log(title = "用户与他人电子名片绑定记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DUserBcd dUserBcd)
    {
        List<DUserBcd> list = dUserBcdService.selectDUserBcdList(dUserBcd);
        ExcelUtil<DUserBcd> util = new ExcelUtil<DUserBcd>(DUserBcd.class);
        return util.exportExcel(list, "用户与他人电子名片绑定记录数据");
    }

    /**
     * 新增用户与他人电子名片绑定记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户与他人电子名片绑定记录
     */
    @RequiresPermissions("system:bcd:add")
    @Log(title = "用户与他人电子名片绑定记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DUserBcd dUserBcd)
    {
        return toAjax(dUserBcdService.insertDUserBcd(dUserBcd));
    }

    /**
     * 修改用户与他人电子名片绑定记录
     */
    @RequiresPermissions("system:bcd:edit")
    @GetMapping("/edit/{userBcdId}")
    public String edit(@PathVariable("userBcdId") Long userBcdId, ModelMap mmap)
    {
        DUserBcd dUserBcd = dUserBcdService.selectDUserBcdByUserBcdId(userBcdId);
        mmap.put("dUserBcd", dUserBcd);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户与他人电子名片绑定记录
     */
    @RequiresPermissions("system:bcd:edit")
    @Log(title = "用户与他人电子名片绑定记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DUserBcd dUserBcd)
    {
        return toAjax(dUserBcdService.updateDUserBcd(dUserBcd));
    }

    /**
     * 删除用户与他人电子名片绑定记录
     */
    @RequiresPermissions("system:bcd:remove")
    @Log(title = "用户与他人电子名片绑定记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(dUserBcdService.deleteDUserBcdByUserBcdIds(ids));
    }
}
